package com.eduhzy.ttw.teacher.mvp.model;

import android.app.Application;

import com.eduhzy.ttw.commonsdk.entity.CommonData;
import com.eduhzy.ttw.commonsdk.entity.MineClassData;
import com.eduhzy.ttw.commonsdk.entity.SchoolTypeData;
import com.eduhzy.ttw.commonsdk.http.CommonApi;
import com.eduhzy.ttw.teacher.mvp.contract.ChooseSchoolContract;
import com.eduhzy.ttw.teacher.mvp.model.api.Api;
import com.eduhzy.ttw.teacher.mvp.model.entity.ChooseSchoolData;
import com.google.gson.Gson;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @author xubo
 * @date 2018-7-19 10:06:17
 */
@ActivityScope
public class ChooseSchoolModel extends BaseModel implements ChooseSchoolContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public ChooseSchoolModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<CommonData<ChooseSchoolData[]>> getGroupbyAreaMap(Map<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(Api.class).getGroupbyAreaMap(map);
    }

    @Override
    public Observable<CommonData<List<MineClassData>>> getClassByUser(Map<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(CommonApi.class).getClassByUser(map);
    }

    @Override
    public Observable<CommonData<Map>> savePersonGroup(Map<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(CommonApi.class).savePersonGroup(map);
    }

    @Override
    public Observable<CommonData<List<SchoolTypeData>>> getBaseCodeByType(Map<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(CommonApi.class).getBaseCodeByType(map);
    }

    @Override
    public Observable<CommonData<Map>> saveGroupApply(Map<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(CommonApi.class).saveGroupApply(map);
    }
}